package powtorka.sieciowa.bis;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class Serwer {
	
	ServerSocket gniazdoSerwera;
	
	public void start() {
		try {
			gniazdoSerwera = new ServerSocket(4200);
			System.out.println("Serwer up");
		} catch (IOException e) {
			e.printStackTrace();
		}

		while(true){
			System.out.println("Server listening");
			try {
				Socket gniazdo = gniazdoSerwera.accept();
				BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(gniazdo.getOutputStream()));
				bw.write("Ala ma kota.");
				bw.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}
